/******
 * File name: TextStyle.java
 *
 * To set the font style of the given text.
 *
 * Author: Ho Yu Fan
 *
 * History:
 *   3-Mar-2014 First Create.
 */

package com.franklin.icharm;

import android.content.Context;
import android.text.Html;
import android.text.Spanned;

public class TextStyle
{
	public static String setStyle(Context c, int id)
	{
		return setStyle(c.getString(id));
		
	} // setStyle

	public static Spanned setSpan(Context c, int id)
	{
		return Html.fromHtml(setStyle(c, id));
	} // setSpan

	public static Spanned setSpan(String str)
	{
		return Html.fromHtml(setStyle(str));
	} // setSpan

	public static String setStyle(String str)
	{
		str = str.replace("[red]", "<font color=\"red\"><b>");
		str = str.replace("[orange]", "<font color=\"#FFA500\"><b>");
		str = str.replace("[yellow]", "<font color=\"#CACA00\"><b>");
		str = str.replace("[green]", "<font color=\"#20B000\"><b>");
		str = str.replaceAll("\\[/\\]", "</b></font>");
		return str;
	} // setStyle
} // TextStyle
